{extend name="admin/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/product.css">
<style type="text/css">
.fun-a {
	margin-top: 0px;
	padding: 6px 15px 0 15px;
}
.style0list tbody td a{
	margin-left: 8px;
}
.num{width:40px;text-align:center;}	
.cell_total{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;width:250px;display: block;}
.style0list table input {
	margin-bottom: 0px;
}

.style0list table input.sort {
	width: auto;
	text-align: center;
}

.style0list tbody td {
	line-height: 28px;
}
</style>
{/block}
{block name="right_tab"}
<li><a class="nscs-table-handle_green" href="ADMIN_MAIN/shop/addpickuppoint" ><i class="fa fa-plus-circle"></i>&nbsp;添加自提点</a></li>
{/block}
{block name="main"}
<!-- <div class="operation">
	<a class="btn btn-small fun-a" href="javascript:batchDelete()">批量删除</a>
</div> -->
<div class="mod-table">
	<div class="mod-table-head">
		<table class="mytable">
			<tr>
				<th width="2%" style="text-align: left;">
					<a class="btn btn-small fun-a" href="javascript:batchDelete()">批量删除</a>
				</th>
				<th width="20%">
					<input type="text" id = 'search_text' placeholder="请输入自提名称" />
					<input type="button" onclick="searchData()" value="搜索" />
				</th>
			</tr>
		</table>

	<div class="con style0list">
		<table>
			 <colgroup>
				<col style="width: 1%">
				<col style="width: 10%;">
				<col style="width: 20%;">
				<col style="width: 10%;">
				<col style="width: 10%;">
				<col style="width: 14%;">
				<col style="width: 15%;">
			</colgroup>
			<thead>
				<tr align="center">
					<th><label><input id="ckall" type="checkbox" onClick="CheckAll(this)"></label></th>
					<th class="x-tab"><div class="iconbg-arrow up">自提名称</div></th>
					<th class="x-tab tal"><div class="iconbg-arrow up">地址</div></th>
					<th class="x-tab tal"><div class="iconbg-arrow up">联系人</div></th>
					<th class="x-tab"><div class="iconbg-arrow up">联系电话</div></th>
					<th class="x-tab"><div class="iconbg-arrow up">发布时间</div></th>
					<th class="x-tab">操作</th>
				</tr>
			</thead>
			<tbody></tbody>
		</table>
	</div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
//分页数据
function LoadingInfo(page_index) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/shop/pickuppointlist')}",
		async : true,
		data : {
			"page_index" : page_index, "page_size" : $("#showNumber").val(), "search_text" : search_text
		},
		success : function(data) {
			//alert(JSON.stringify(data));
			var html = '';
			if (data["data"].length > 0) {
				for (var i = 0; i < data["data"].length; i++) {
					html += '<tr align="center">';
					html += '<td><div class="cell"><label><input name="sub" type="checkbox" value="'+ data['data'][i]['id']+'" ></label></div></td>';
					html += '<td><div>' + data["data"][i]["name"]+ '</div></td>';	
					html += '<td class="tal">'+ data["data"][i]["province_name"]+ '/'+ data["data"][i]["city_name"]+ '/' + data["data"][i]["dictrict_name"]+ '/'+ data["data"][i]["address"]+'</td>';
					
					html += '<td class="tal">' + data["data"][i]["contact"]+ '</td>';
					html += '<td>'+data["data"][i]["phone"]+'</td>'
					html += '<td>' + timeStampTurnTime(data["data"][i]["create_time"])+ '</td>';
					html += '<td><a href="ADMIN_MAIN/shop/updatepickuppoint?id='+ data['data'][i]['id']+'">修改</a><a style="cursor: pointer;" onclick="deletepickupPoint('+data['data'][i]['id']+')">删除</a></td> ';
					html += '</tr>';
				}
			} else {
				html += '<tr align="center"><th colspan="9">暂无自提点</th></tr>';
			}
			$(".style0list tbody").html(html);
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
// 			load();
		}
	});
}	

function batchDelete() {
	var pickupPoint_id= new Array();
	$(".style0list tbody input[type='checkbox']:checked").each(function() {
		if (!isNaN($(this).val())) {
			pickupPoint_id.push($(this).val());
		}
	});
	if(pickupPoint_id.length ==0){
		$( "#dialog" ).dialog({
			buttons: {
				"确定,#e57373": function() {
					$(this).dialog('close');
				}
			},
			contentText:"请选择需要操作的记录",
			title:"消息提醒",
		});
		return false;
	}
	deletepickupPoint(pickupPoint_id);
}
var flag = false;
//删除
function deletepickupPoint(pickupPoint_id){
	$( "#dialog" ).dialog({
		buttons: {
			"确定": function() {
				$(this).dialog('close');
				if(!flag){
					flag = true;
					$.ajax({
						type : "post",
						url : "{:__URL('ADMIN_MAIN/shop/deletepickuppoint')}",
						data : {
							"pickupPoint_id" : pickupPoint_id.toString()
						},
						dataType : "json",
						success : function(data) {
							if (data["code"] > 0) {
								showMessage('success', data["message"]);
								window.location.href=__URL("ADMIN_MAIN/shop/pickuppointlist");
							}else{
								showMessage('error', data["message"]);
							}
							flag = false;
						}
					})
				}
			},
			"取消,#e57373": function() {
				$(this).dialog('close');
			}
		},
	contentText:"是否删除该自提点？",
	});
}

// /*修改排序*/
// function load(){
// 	$('.num').change(function(){
// 		var fieldid = $(this).attr('fieldid');
// 		var sort = $(this).val();
// 		$.ajax({
// 			type:"post",
// 			url:"ADMIN_MAIN/Cms/modifyArticleField",
// 			data:{'fieldid':fieldid,'sort':sort},
// 			async:true,
// 			success: function (data) {
// 				if(data['code'] <= 0){
// 					showMessage('error', data["message"]);
// 				}
// 			}
// 		});
// 	});
// }
//全选
function CheckAll(event){
	var checked = event.checked;
	$(".style0list tbody input[type = 'checkbox']").prop("checked",checked);
}
function searchData(){
	LoadingInfo(1);
}
</script>
{/block}